namespace GemBox.Spreadsheet
{
    using GemBox;
    using System;
    using System.Globalization;

    public sealed class SpreadsheetInfo
    {
        internal const string AssemblyName = "GemBox.Spreadsheet";
        public const string FullVersion = "29.3.0.1055";
        internal static int LicenseReleaseID = (2 + int.Parse("29", CultureInfo.InvariantCulture));
        private static GXLicensing licensing = new GXLicensing();
        private const string Name = "GemBox.Spreadsheet Professional 2.9";
        private const string RevisionStr = "1055";
        public const string Title = "GemBox.Spreadsheet Professional 2.9 for .NET 2.0";
        private const string TypeStr = "3";
        private const string VersionLong = "2.9";
        private const string VersionShort = "29";

        private SpreadsheetInfo()
        {
        }

        private static string GetCleanKey(string enteredKey)
        {
            if (enteredKey.Length != 0x13)
            {
                return null;
            }
            string[] strArray = enteredKey.Split(new char[] { '-' });
            if (strArray.Length != 4)
            {
                return null;
            }
            foreach (string str in strArray)
            {
                if (str.Length != 4)
                {
                    return null;
                }
            }
            return (strArray[0] + strArray[1] + strArray[2] + strArray[3]);
        }

        public static void SetLicense(string serialKey)
        {
            licensing.SetLicense(serialKey);
        }

        internal static void ValidateLicense(ExcelFile caller)
        {
            if (!licensing.ValidateLicense(LicenseReleaseID, ref caller.HashFactorA, ref caller.HashFactorB))
            {
                throw new Exception("License not set. Call SpreadsheetInfo.SetLicense() method before using any other class from GemBox.Spreadsheet Professional library.");
            }
        }
    }
}
